package com.zhengshang.web.controller.app;

import com.zhengshang.api.domain.AppThirdColumn;
import com.zhengshang.api.service.IAppThirdColumnService;
import com.zhengshang.common.annotation.Log;
import com.zhengshang.common.core.controller.BaseController;
import com.zhengshang.common.core.domain.AjaxResult;
import com.zhengshang.common.core.page.TableDataInfo;
import com.zhengshang.common.enums.BusinessType;
import com.zhengshang.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author zhengshang
 * @date 2022-04-10
 */
@RestController
@RequestMapping("/app/thirdColumn")
public class AppThirdColumnController extends BaseController {
    @Autowired
    private IAppThirdColumnService appThirdColumnService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('app:column:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppThirdColumn appThirdColumn) {
        startPage();
        List<AppThirdColumn> list = appThirdColumnService.selectAppThirdColumnList(appThirdColumn);
        return getDataTable(list);
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/queryList")
    public AjaxResult queryList(AppThirdColumn appThirdColumn) {
        List<AppThirdColumn> list = appThirdColumnService.selectAppThirdColumnList(appThirdColumn);
        return AjaxResult.success(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('app:column:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppThirdColumn appThirdColumn) {
        List<AppThirdColumn> list = appThirdColumnService.selectAppThirdColumnList(appThirdColumn);
        ExcelUtil<AppThirdColumn> util = new ExcelUtil<AppThirdColumn>(AppThirdColumn.class);
        return util.exportExcel(list, "column");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:column:query')")
    @GetMapping(value = "/{thirdColumnId}")
    public AjaxResult getInfo(@PathVariable("thirdColumnId") Long thirdColumnId) {
        return AjaxResult.success(appThirdColumnService.selectAppThirdColumnById(thirdColumnId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('app:column:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppThirdColumn appThirdColumn) {
        appThirdColumn.setThirdColumnSyscstate(0);
        return toAjax(appThirdColumnService.insertAppThirdColumn(appThirdColumn));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('app:column:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppThirdColumn appThirdColumn) {
        return toAjax(appThirdColumnService.updateAppThirdColumn(appThirdColumn));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('app:column:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{thirdColumnIds}")
    public AjaxResult remove(@PathVariable Long[] thirdColumnIds) {
        return toAjax(appThirdColumnService.deleteAppThirdColumnByIds(thirdColumnIds));
    }
}
